package com.example.teamtribe.main.mine.setting.email;

import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.example.teamtribe.R;
import com.example.teamtribe.base.BaseActivity;

public class EmailActivity extends BaseActivity implements View.OnClickListener, EmailContract.View {

    LinearLayout llFill;
    EditText etEmail;
    TextView tvMeg;
    EmailContract.Presenter presenter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_email);

        etEmail = findViewById(R.id.et_email);
        tvMeg = findViewById(R.id.tv_meg);
        llFill = findViewById(R.id.ll_fill);
        presenter = new EmailPresenter(this);

        findViewById(R.id.bt_email).setOnClickListener(this);

        ((TextView) findViewById(R.id.tv_title)).setText("邮箱验证");
        etEmail.setText(getIntent().getStringExtra("email"));
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.bt_email:
                presenter.sendEmail(etEmail.getText().toString().trim());
                break;

            default:
                break;
        }
    }

    @Override
    public void setView(final String meg) {
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                llFill.setVisibility(View.GONE);
                tvMeg.setText(meg);
                tvMeg.setVisibility(View.VISIBLE);
            }
        });
    }
}
